// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

TestCase := Rectangle {
    property<{a: string, b: int}> foo: {a : "444", b: 12 };
    property<{a: string, b: int}> obj_conversion: { b: 12, a : 444, c: "nothing" };
    property<{a: string, b: int}> obj_conversion2: { a: "hello" };
    property<{a: string, b: int}> obj_cond: true ? { b: 12, a : "ddd" } :  { a: 12, b : 444, c: "nothing" };
    property<{a: int, b: int}> obj_cond_merge : true ? { a: 1 } : { b: 10 };
    property<bool> obj_binop_merge : { foo: 0, x: 1 } == { bar: 0, x: 1 };

    property<string> foo_a : foo.a;
    property<int> foo_b : foo.b;
    property<int> obj_cond_merge_b : obj_cond_merge.b;
    callback change_foo;
    change_foo => {
        foo.a = obj_conversion2.a;
        foo.b += 8 + obj_conversion2.b;
    }

    function return_object() -> { aa: { bb: int } }
    { return { aa: { bb: { cc: 42 }.cc } }; }
    property <bool> test: return_object().aa.bb == 42 && obj_binop_merge;

}


/*
```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_foo_a(), slint::SharedString::from("444"));
assert_eq!(instance.get_foo_b(), 12);
instance.invoke_change_foo();
assert_eq!(instance.get_foo_a(), slint::SharedString::from("hello"));
assert_eq!(instance.get_foo_b(), 20);
assert_eq!(instance.get_obj_cond_merge_b(), 0);
assert!(instance.get_obj_binop_merge());
assert!(instance.get_test());

// This API to set with a tuple should maybe not be accessible?
instance.set_foo(("yo".into(), 33));
assert_eq!(instance.get_foo_a(), slint::SharedString::from("yo"));
assert_eq!(instance.get_foo_b(), 33);

```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_foo_a(), slint::SharedString("444"));
assert_eq(instance.get_foo_b(), 12);
instance.invoke_change_foo();
assert_eq(instance.get_foo_a(), slint::SharedString("hello"));
assert_eq(instance.get_foo_b(), 20);
assert_eq(instance.get_obj_cond_merge_b(), 0);
assert_eq(instance.get_obj_binop_merge(), true);
assert(instance.get_test());

// This API to set with a tuple should maybe not be accessible?
instance.set_foo(std::make_tuple(slint::SharedString("yo"), 33));
assert_eq(instance.get_foo_a(), slint::SharedString("yo"));
assert_eq(instance.get_foo_b(), 33);
```


```js
var instance = new slint.TestCase({});
assert.equal(instance.foo_a, ("444"));
assert.equal(instance.foo_b, 12);
instance.change_foo();
assert.equal(instance.foo_a, "hello");
assert.equal(instance.foo_b, 20);
assert.equal(instance.obj_cond_merge_b, 0);
assert(instance.obj_binop_merge);
assert(instance.test);

instance.foo = { a: "yo", b: 33 };
assert.equal(instance.foo_a, "yo");
assert.equal(instance.foo_b, 33);
```
*/
